/*
 * Niiuzu
 * Copyright (C) 2011  Thierry Nowak
 * 
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.niiuzu.client.screen.feed.actions;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.mvp4g.client.annotation.Presenter;
import com.mvp4g.client.presenter.LazyPresenter;
import com.niiuzu.client.eventbus.FeedEventBus;

/**
 * Presenter de l'écrans contenant les liens déclenchant les actions sur les
 * flux et les thèmes.
 */
@Presenter(view = FeedActionsViewImpl.class)
public class FeedActionsPresenter extends
		LazyPresenter<FeedActionsView, FeedEventBus> {

	private ClickHandler addChannelGroupClickHandler;

	private ClickHandler addChannelClickHandler;

	@Override
	public void bindView() {
		super.bindView();

		addChannelClickHandler = new ClickHandler() {
			@Override
			public void onClick(ClickEvent event) {
				eventBus.newChannelAsked();
			}
		};
		view.getAddChannelHasClickHandlers().addClickHandler(
				addChannelClickHandler);

		addChannelGroupClickHandler = new ClickHandler() {
			@Override
			public void onClick(ClickEvent event) {
				eventBus.newChannelGroupAsked();
			}
		};
		view.getAddChannelGroupHasClickHandlers().addClickHandler(
				addChannelGroupClickHandler);
	}

	/**
	 * Lancement du chargement de la vue des actions sur les flux.
	 * 
	 * @see FeedEventBus#feedActionsLoadingStarted()
	 */
	public void onFeedActionsLoadingStarted() {
		eventBus.feedActionsLoaded(view);
	}

	/**
	 * Comportement d'un clic sur le composant de l'ajout de flux.
	 */
	public ClickHandler getAddChannelClickHandler() {
		return addChannelClickHandler;
	}

	/**
	 * Comportement d'un clic sur le composant de l'ajout de thèmes.
	 */
	public ClickHandler getAddChannelGroupClickHandler() {
		return addChannelGroupClickHandler;
	}
}
